package handle

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"yk1/api/basic/config"
	__ "yk1/api/basic/proto"
	"yk1/api/request"
)

func AdministratorsAdd(c *gin.Context) {
	var req request.AdministratorsAddReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusOK, gin.H{
			"code": 400,
			"msg":  "参数验证失败",
			"data": err.Error(),
		})
		return
	}
	r, err := config.Client.AdministratorsAdd(c, &__.AdministratorsAddReq{
		UserId:       req.UserId,
		PermissionId: req.PermissionId,
	})
	if err != nil {
		c.JSON(http.StatusOK, gin.H{
			"code": 400,
			"msg":  "权限添加失败",
			"data": err.Error(),
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "权限添加成功",
		"data": r,
	})

}
